﻿using DevExpress.XtraEditors;
using DevExpress.XtraGrid.Views.Grid;
using RecruitStudents.Client.BLL;
using RecruitStudents.Utility;
using RecruitStudents.Utility.Helper;
using RecruitStudents.Utility.Model;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Drawing.Printing;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace RecruitStudents.Client.Lottery
{
    public partial class Lottery_MakeLotteryForm_First_List : BaseForm
    {
        #region 读卡器
        public int iRetUSB = 0;
        public int iRetCOM = 0;

        public StringBuilder name;      //姓名
        public String sex;              //性别
        public String people;           //民族，护照识别时此项为空
        public String birthday;         //出生日期
        public String address;          //地址，在识别护照时导出的是国籍简码
        public string number;           //地址，在识别护照时导出的是国籍简码
        public string signdate;         //签发日期，在识别护照时导出的是有效期至 
        public string validtermOfStart; //有效起始日期，在识别护照时为空
        public string validtermOfEnd;   //有效截止日期，在识别护照时为空

        //扫描结构：
        [StructLayout(LayoutKind.Sequential, Size = 16, CharSet = CharSet.Ansi)]
        public struct IDCARD_ALL
        {
            [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 30)]
            public char name;               //姓名
            [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 3)]
            public char sex;                //性别
            [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 4)]
            public char people;             //民族，护照识别时此项为空
            [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 16)]
            public char birthday;           //出生日期
            [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 70)]
            public char address;            //地址，在识别护照时导出的是国籍简码
            [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 36)]
            public char number;             //地址，在识别护照时导出的是国籍简码
            [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 30)]
            public char signdate;           //签发日期，在识别护照时导出的是有效期至 
            [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 16)]
            public char validtermOfStart;   //有效起始日期，在识别护照时为空
            [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 16)]
            public char validtermOfEnd;     //有效截止日期，在识别护照时为空
        }

        private void InitCardData()
        {
            try
            {
                int iPort;
                for (iPort = 1001; iPort <= 1016; iPort++)
                {
                    iRetUSB = CheckIDCard.CVR_InitComm(iPort);
                    if (iRetUSB == 1)
                        break;
                }

                for (iPort = 1; iPort <= 4; iPort++)
                {
                    iRetCOM = CheckIDCard.CVR_InitComm(iPort);
                    if (iRetCOM == 1)
                        break;
                }

                if ((iRetCOM == 1) || (iRetUSB == 1))
                {
                    this.groupSFZ.Text = "设置、扫描区（初始化成功）";
                }
                else
                {
                    this.groupSFZ.Text = "设置、扫描区（初始化失败）";
                }
            }
            catch
            {

            }
        }

        #endregion
        //ServiceAppointment serviceAppoint = new ServiceAppointment();
        ServiceComm serviceComm = new ServiceComm();
        ServiceLottery service = new ServiceLottery();
        ServiceExaminee serviceExaminee = new ServiceExaminee();

        private System.Windows.Forms.PrintDialog PrintDialog1 = new PrintDialog();
        private System.Drawing.Printing.PrintDocument docToPrint = new System.Drawing.Printing.PrintDocument();
        private UserInfo StudentUserInfo = null;

        public Lottery_MakeLotteryForm_First_List()
        {
            InitializeComponent();
            InitCardData();
            txtIdCard.KeyPress += txtIdCard_KeyPress;
            BindGroup();
            ClearTextBox();
        }

        private void txtIdCard_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (CheckIDCard.CheckTextEditIdCardNo(txtIdCard, e))
            {
                CheckAppointmentStudents(txtIdCard.Text.Trim());
            }
        }
        private void CheckAppointmentStudents(string idCard)
        {
            DataTable dt = service.CheckTB_Pad_Signed_New(SessionerHelper.SpecialityKindsNO, SessionerHelper.ExamLevel, SessionerHelper.ExamPlaceID, idCard, SessionerHelper.SystemYear);
            if (dt == null || dt.Rows.Count == 0)
            {
                DevHelper.ShowErrorMessageBox("没有查到该考生信息，请确认是否进行了现场确认！");
                return;
            }
            else
            {
                if (dt.Rows[0]["AllowExamID"].ToString().Trim() == "")
                {
                    DevHelper.ShowErrorMessageBox("该考生的准考证号为空，请先进行现场确认！");
                    return;
                }
                string SignUpID = dt.Rows[0]["SignUpID"].ToSafeString();
                lbGuid.Text = SignUpID;
                lbCXJG.Text = "查询成功。";
                lbKSZG.Text = "有效";
                lbKSJB.Text = "初试";
                lbXM.Text = dt.Rows[0]["Name"].ToString().Trim();
                lbSFZH.Text = dt.Rows[0]["IdentityCard"].ToString().Trim();
                lbKSH.Text = dt.Rows[0]["NMT_SignUpID"].ToString().Trim();
                lbZKZH.Text = dt.Rows[0]["AllowExamID"].ToString().Trim();
                lbSYD.Text = dt.Rows[0]["ExamProvinceName"].ToSafeString();
                lbLXDH.Text = dt.Rows[0]["LinkMobile"].ToString().Trim();
                lbCCH.Text = dt.Rows[0]["LotNO"] != null ? dt.Rows[0]["LotNO"].ToString() : "";
                lbCCSJ.Text = dt.Rows[0]["LotTime"] != null ? dt.Rows[0]["LotTime"].ToString() : "";
                if (dt.Rows[0]["LotNO"] != null && !string.IsNullOrEmpty(dt.Rows[0]["LotNO"].ToString()))
                {
                    DevHelper.ShowErrorMessageBox("该考生已经抽签，信息如下：抽签号-》" + dt.Rows[0]["LotNO"].ToString() + " 抽签时间-》" + dt.Rows[0]["LotTime"].ToString() + "");
                    ClearTextBox();
                    return;
                }
                try
                {
                    using (DataSet ds = serviceExaminee.GetStudentsPhoto(SignUpID))
                    {
                        if (ds != null && ds.Tables[0].Rows.Count > 0)
                        {
                            byte[] bytes = (byte[])ds.Tables[0].Rows[0]["Photo"];
                            using (MemoryStream ms = new MemoryStream(bytes))
                            {
                                Image img = Image.FromStream(ms);
                                ms.Close();
                                this.pictureBox1.Image = img;
                            }
                        }
                    }
                }
                catch
                { }

                using (DataTable dtExamSpec = serviceExaminee.GetExameeSpecialityBySignUpID(lbGuid.Text))
                {
                    if (dtExamSpec != null && dtExamSpec.Rows.Count > 0)
                    {
                        DataRow[] drsExamSpec = dtExamSpec.Select("ExamPlaceNO='" + SessionerHelper.ExamPlaceID + "' and ExamLevel='" + SessionerHelper.ExamLevel + "' and SpecialityKindsNO in (" + SessionerHelper.SpecialityKindsNO + ")");
                        if (drsExamSpec.Length > 0)
                        {
                            string strGroupNo = drsExamSpec[0]["AppointmentGroup_First"].ToSafeString();
                            var lotteryNo = serviceComm.CreateLotteryNO(strGroupNo);
                            if (XtraMessageBox.Show("该考生抽签号为：" + lotteryNo, "确认", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) == DialogResult.Yes)
                            {
                                service.MakeLottery_New(SignUpID, SessionerHelper.ExaminationID, lotteryNo, SessionerHelper.ExamPlaceID, SessionerHelper.ExamLevel, SessionerHelper.SpecialityKindsNO, SessionerHelper.SystemYear);
                                BindGridViewLot();
                                #region 测试打印   
                                try
                                {
                                    StudentUserInfo = new UserInfo();
                                    StudentUserInfo.SFZH = lbSFZH.Text;
                                    StudentUserInfo.XM = lbXM.Text;
                                    StudentUserInfo.XB = (dt.Rows[0]["Sex"].ToSafeString() == "1" ? "男" : "女");
                                    StudentUserInfo.ZKZH = lbZKZH.Text;
                                    StudentUserInfo.KSKM = SessionerHelper.SpecialityKinds;
                                    StudentUserInfo.KSH = lotteryNo;
                                    if (SessionerHelper.SpecialityKindsNO.Contains("1303010_A"))
                                    {
                                        StudentUserInfo.KSKM = "声台形科目";
                                        StudentUserInfo.PrintType = 2;//下划线
                                    }
                                    else if (SessionerHelper.SpecialityKindsNO.Contains("1303090"))
                                    {
                                        StudentUserInfo.KSKM = "播音主持";
                                        StudentUserInfo.PrintType = 3;//圆圈
                                    }
                                    else
                                    {
                                        StudentUserInfo.KSKM = "表演科目";
                                        StudentUserInfo.PrintType = 1;
                                    }
                                    InitPrint();
                                }
                                catch
                                { }
                                #endregion
                                ClearTextBox();
                            }
                            else
                            {
                                return;
                            }
                        }
                        else
                        {
                            DevHelper.ShowErrorMessageBox("该考生没有报考合格的专业！");
                        }
                    }
                    else
                    {
                        DevHelper.ShowErrorMessageBox("该考生没有报考合格的专业！");
                    }
                }
            }
        }

        private void gridView2_DoubleClick(object sender, EventArgs e)
        {
            if (gridView2.GetFocusedValue() != null)
            {
                if (XtraMessageBox.Show("是否要重新打印该考生的抽签号？", "确认", MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation) == DialogResult.OK)
                {
                    var LotNO = gridView2.GetFocusedRowCellValue("LotNO").ToString();
                    var IdentityCard = gridView2.GetFocusedRowCellValue("IdentityCard").ToString();
                    var Name = gridView2.GetFocusedRowCellValue("Name").ToString();
                    #region 测试打印   
                    try
                    {
                        using (DataTable dt = serviceExaminee.GetExameeByIdentityCard(IdentityCard))
                        {
                            if (dt != null && dt.Rows.Count > 0)
                            {
                                StudentUserInfo = new UserInfo();
                                StudentUserInfo.SFZH = IdentityCard;
                                StudentUserInfo.XM = Name;
                                StudentUserInfo.XB = (dt.Rows[0]["Sex"].ToSafeString() == "1" ? "男" : "女");
                                StudentUserInfo.ZKZH = lbZKZH.Text;
                                StudentUserInfo.KSKM = SessionerHelper.SpecialityKinds;
                                StudentUserInfo.KSH = LotNO;
                                if (SessionerHelper.SpecialityKindsNO.Contains("1303010_A"))
                                {
                                    StudentUserInfo.KSKM = "声台形科目";
                                    StudentUserInfo.PrintType = 2;//下划线
                                }
                                else if (SessionerHelper.SpecialityKindsNO.Contains("1303090"))
                                {
                                    StudentUserInfo.KSKM = "播音主持";
                                    StudentUserInfo.PrintType = 3;//圆圈
                                }
                                else
                                {
                                    StudentUserInfo.KSKM = "表演科目";
                                    StudentUserInfo.PrintType = 1;
                                }
                                InitPrint();
                            }
                            else
                            {
                                DevHelper.ShowErrorMessageBox("根据身份证号读取考生信息出现错误！");
                            }
                        }
                    }
                    catch
                    { }
                    #endregion
                }
            }
            if (gridView2.GetFocusedValue() != null)
            {
                //var SignedID = gridView2.GetFocusedRowCellValue("SignedID").ToString();
                //if (SignedID != "")
                //{
                //    if (XtraMessageBox.Show("是否确认取消该考生的抽签信息？", "确认", MessageBoxButtons.OKCancel,MessageBoxIcon.Exclamation) == DialogResult.OK)
                //    {
                //        var strGroupNo = gridView1.GetFocusedRowCellValue("GroupNo").ToString();
                //        var signUpStudentsSpecialityId = gridView2.GetFocusedRowCellValue("SignUpStudentsSpecialityID").ToString();

                //        bool flag = service.CancelLottery(strGroupNo, signUpStudentsSpecialityId, SignedID);
                //        if (flag)
                //        {
                //            InitStudents();
                //        }
                //    }
                //}
            }
        }


        private void ClearTextBox()
        {
            txtIdCard.Text = "";
            lbGuid.Text = "";
            lbCXJG.Text = "";
            lbKSZG.Text = "";
            lbKSJB.Text = "";
            lbXM.Text = "";
            lbSFZH.Text = "";
            lbKSH.Text = "";
            lbZKZH.Text = "";
            lbSYD.Text = "";
            lbLXDH.Text = "";
            lbCCH.Text = string.Empty;
            lbCCSJ.Text = string.Empty;
            //lbJFZT.Text = "";
            //lbYYZB.Text = "";
            //lbYYSJ.Text = "";
            pictureBox1.Image = null;

        }

        private void InitStudents()
        {
            BindGridViewLot();
            AddControl();
        }
        private void BindGridViewLot()
        {
            //var strGroupNo = string.Empty;
            //if (gridView1.DataSource != null)
            //{
            //    strGroupNo = (gridView1.GetFocusedRowCellValue("GroupNo") ?? "").ToString();
            //}
            //var dt = service.GetTB_Pad_SignedDataTable(strGroupNo, SessionerHelper.ExamLevel, SessionerHelper.SpecialityKindsNO);
            //if (dt != null)
            //{
            //    if (gridView1.FocusedRowHandle >= 0)
            //    {
            //        gridView1.SetRowCellValue(gridView1.FocusedRowHandle, ActualAcount, dt.Rows.Count);
            //    }
            //}
            //else
            //{
            //    if (gridView1.FocusedRowHandle >= 0)
            //    {
            //        gridView1.SetRowCellValue(gridView1.FocusedRowHandle, ActualAcount, 0);
            //    }
            //}
        }

        private void BindGroup()
        {
            InitStudents();
            //try
            //{
            //    using (DataTable dt = serviceComm.GetAppointmentGroupDataTable(SessionerHelper.ExamPlaceID, SessionerHelper.SpecialityKindsNO, SessionerHelper.ExamLevel))
            //    {
            //        gdAppointment.DataSource = dt;
            //        InitStudents();
            //    }
            //}
            //catch (Exception ex)
            //{
            //    DevHelper.ShowErrorMessageBox(ex.Message);
            //}
        }
        private void AddControl()
        {
            //var strGroupNo = (gridView1.GetFocusedRowCellValue("GroupNo") ?? "").ToString();
            //this.xtraScrollableControl1.Controls.Clear();
            //using (DataTable dtExamRoom = serviceComm.GetExamRoomTableByEntretenimientohID(SessionerHelper.ExaminationID))
            //{
            //    if (dtExamRoom != null)
            //    {
            //        LotteryMakeLotteryForm_First_ExamRoomControl examRoom = null;
            //        for (int i = 0; i < dtExamRoom.Rows.Count; i++)
            //        {
            //            examRoom = new LotteryMakeLotteryForm_First_ExamRoomControl(dtExamRoom.Rows[i]["ExamRoomNO"].ToSafeString(), strGroupNo,
            //                dtExamRoom.Rows[i]["ExamRoomName"].ToSafeString());
            //            examRoom.Text = dtExamRoom.Rows[i]["ExamRoomName"].ToSafeString();
            //            examRoom.Location = CalculatePoint(i, 4);
            //            examRoom.Distribution += btn_Distribution_Click;
            //            examRoom.GridViewDoubleClick += ExamRoomUserControl_gridView2_DoubleClick;
            //            examRoom.DataGridBind();
            //            this.xtraScrollableControl1.Controls.Add(examRoom);
            //        }
            //    }
            //}
        }

        private void ExamRoomUserControl_gridView2_DoubleClick(object sender, EventArgs e)
        {
            BindGridViewLot();
        }

        private void btn_Distribution_Click(object sender, EventArgs e)
        {
            //var examRoom = sender as LotteryMakeLotteryForm_First_ExamRoomControl;
            //string strGroupNo = (gridView1.GetFocusedRowCellValue("GroupNo") ?? "").ToString();
            //List<TB_Pad_Queue> list = new List<TB_Pad_Queue>();
            //DataTable dt = this.gdAppointmentStudents.DataSource as DataTable;
            //if (dt != null)
            //{
            //    for (int i = 0; i < dt.Rows.Count; i++)
            //    {
            //        if (Convert.ToBoolean(dt.Rows[i]["IsCheck"]) && string.IsNullOrEmpty(dt.Rows[i]["SignedID"].ToString()))
            //        {
            //            DevHelper.ShowErrorMessageBox("您选择的考生中还有未抽签的!");
            //            return;
            //        }
            //        if (Convert.ToBoolean(dt.Rows[i]["IsCheck"]) && dt.Rows[i]["SignedID"] != null && !string.IsNullOrEmpty(dt.Rows[i]["SignedID"].ToString()))
            //        {
            //            TB_Pad_Queue model = new TB_Pad_Queue();
            //            model.AllowExamID = dt.Rows[i]["AllowExamID"].ToSafeString();
            //            model.ExamProvince = dt.Rows[i]["ExamProvince"].ToSafeString();
            //            model.CreateTiime = DateTime.Now;
            //            model.ExamRoomNO = examRoom.ExamRoomId;
            //            model.ExamYear = SessionerHelper.SystemYear;
            //            model.GroupNO = strGroupNo;
            //            model.IdentityCard = dt.Rows[i]["IdentityCard"].ToSafeString();
            //            model.LotNO = dt.Rows[i]["LotNO"].ToSafeString();
            //            model.Name = dt.Rows[i]["Name"].ToSafeString();
            //            model.NMT_SignUpID = dt.Rows[i]["NMT_SignUpID"].ToSafeString();
            //            model.SignedID = dt.Rows[i]["SignedID"].ToSafeString();
            //            list.Add(model);
            //        }
            //    }
            //}
            //if (list.Count == 0)
            //{
            //    DevHelper.ShowErrorMessageBox("请先选择考生再进行操作!");
            //    return;
            //}
            //if (service.MakeExamRoomQueue(list))
            //{
            //    InitStudents();
            //}
        }

        private Point CalculatePoint(int sort, int columNum)
        {
            const int examRoomWidth = 280;
            const int examRoomHeight = 240;
            if (columNum == 0)
                columNum = 1;
            var m = sort % columNum;
            var b = sort / columNum;
            return new Point(m * examRoomWidth, b * examRoomHeight);
        }

        private void gridView1_RowClick(object sender, RowClickEventArgs e)
        {
            InitStudents();
        }

        private void MakeLotteryForm_FormClosing(object sender, FormClosingEventArgs e)
        {
            this.timer_ReadID.Enabled = false;
        }
        #region 身份证读卡器
        private void FillData()
        {
            try
            {
                byte[] name = new byte[30];
                int length = 30;
                CheckIDCard.GetPeopleName(ref name[0], ref length);
                //MessageBox.Show();
                byte[] number = new byte[30];
                length = 36;
                CheckIDCard.GetPeopleIDCode(ref number[0], ref length);
                byte[] people = new byte[30];
                length = 3;
                CheckIDCard.GetPeopleNation(ref people[0], ref length);
                byte[] validtermOfStart = new byte[30];
                length = 16;
                CheckIDCard.GetStartDate(ref validtermOfStart[0], ref length);
                byte[] birthday = new byte[30];
                length = 16;
                CheckIDCard.GetPeopleBirthday(ref birthday[0], ref length);
                byte[] address = new byte[30];
                length = 70;
                CheckIDCard.GetPeopleAddress(ref address[0], ref length);
                byte[] validtermOfEnd = new byte[30];
                length = 16;
                CheckIDCard.GetEndDate(ref validtermOfEnd[0], ref length);
                byte[] signdate = new byte[30];
                length = 30;
                CheckIDCard.GetDepartment(ref signdate[0], ref length);
                byte[] sex = new byte[30];
                length = 3;
                CheckIDCard.GetPeopleSex(ref sex[0], ref length);
                txtIdCard.Text = System.Text.Encoding.GetEncoding("GB2312").GetString(number).Replace("\0", "");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
        #endregion
        private void timer_ReadID_Tick(object sender, EventArgs e)
        {
            try
            {
                //删除上次所拍的照片                
                if (System.IO.File.Exists(Application.StartupPath + "\\zp.bmp"))
                {
                    System.IO.File.Delete(Application.StartupPath + "\\zp.bmp");
                }

                if ((iRetCOM == 1) || (iRetUSB == 1))
                {
                    int authenticate = CheckIDCard.CVR_Authenticate();
                    if (authenticate == 1)
                    {
                        int readContent = CheckIDCard.CVR_Read_Content(4);
                        if (readContent == 1 || readContent == 2)
                        {
                            timer_ReadID.Enabled = false;
                            FillData();
                            CheckAppointmentStudents(txtIdCard.Text);
                            this.groupSFZ.Text = "设置、扫描区（读卡成功）";
                            timer_ReadID.Enabled = true;
                        }
                        else
                        {
                            this.groupSFZ.Text = "设置、扫描区（读卡操作失败）";
                        }
                    }
                    else
                    {
                    }
                }
                else
                {
                }
            }
            catch (Exception ex)
            {
                DevHelper.ShowErrorMessageBox(ex.ToString());
            }
        }

        #region 初始化打印类属性
        /// <summary>
        /// 初始化打印类属性
        ///  </summary>
        private void InitPrint()
        {
            if (StudentUserInfo == null)
            {
                return;
            }
            docToPrint.PrintPage += new PrintPageEventHandler(docToPrint_PrintPage);
            PrintDialog1.AllowSomePages = true;
            PrintDialog1.ShowHelp = true;
            this.docToPrint.Print();
        }
        #endregion

        #region 打印事件
        /// <summary>
        /// 打印事件 【1：普通 2：线  3：圈】
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void docToPrint_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
        {
            if (StudentUserInfo.PrintType == 2)
            {
                e.Graphics.DrawLine(new Pen(Color.Black, 5), 70, 450, 320, 450);
                e.Graphics.DrawLine(new Pen(Color.Black, 5), 70, 850, 320, 850);
            }
            else if (StudentUserInfo.PrintType == 3)
            {
                e.Graphics.DrawEllipse(new Pen(Color.Black, 5), 40, 220, 300, 300);//画椭圆的方法，x坐标、y坐标、宽、高，如果是100，则半径为50
                e.Graphics.DrawEllipse(new Pen(Color.Black, 5), 40, 620, 300, 300);//画椭圆的方法，x坐标、y坐标、宽、高，如果是100，则半径为50
            }
            //通过GDI+绘制打印文档
            //BarCode code = new BarCode();
            //code.ValueFont = new System.Drawing.Font("宋体", 12);
            //code.Height = 40;
            //Bitmap image = code.GetCodeImage(StudentUserInfo.KSH, BarCode.Encode.Code128A);
            //e.Graphics.DrawImage(image, 150, 455, image.Width, image.Height);
            e.Graphics.DrawString(StudentUserInfo.KSKM, new Font("宋体", 12, System.Drawing.FontStyle.Bold), Brushes.Black, 150, 250);
            e.Graphics.DrawString(StudentUserInfo.KSH, new Font("宋体", 130, System.Drawing.FontStyle.Bold), Brushes.Black, 20, 280);
            // e.Graphics.DrawLine(new Pen(Color.Black, (float)3.00), 100, 185, 720, 185);
            e.Graphics.DrawString("身份证号：", new Font("宋体", 12), Brushes.Black, 480, 290);
            e.Graphics.DrawString(StudentUserInfo.SFZH, new Font("宋体", 12, System.Drawing.FontStyle.Bold), Brushes.Black, 560, 290);
            e.Graphics.DrawString("姓名：" + StudentUserInfo.XM + "", new Font("宋体", 12), Brushes.Black, 480, 315);
            e.Graphics.DrawString("性别：" + StudentUserInfo.XB + "", new Font("宋体", 12), Brushes.Black, 480, 340);
            e.Graphics.DrawString("准考证号：", new Font("宋体", 12), Brushes.Black, 480, 365);
            e.Graphics.DrawString(StudentUserInfo.ZKZH, new Font("宋体", 12, System.Drawing.FontStyle.Bold), Brushes.Black, 560, 365);
            e.Graphics.DrawString("考试科目：" + StudentUserInfo.KSKM + "", new Font("宋体", 12), Brushes.Black, 480, 390);
            e.Graphics.DrawString("考试号：", new Font("宋体", 12), Brushes.Black, 480, 415);
            e.Graphics.DrawString(StudentUserInfo.KSH, new Font("宋体", 12, System.Drawing.FontStyle.Bold), Brushes.Black, 545, 415);
            e.Graphics.DrawString("请将左侧考试号贴置胸前", new Font("宋体", 12, System.Drawing.FontStyle.Bold), Brushes.Black, 465, 460);

            // e.Graphics.DrawLine(new Pen(Color.Black, (float)3.00), 100, 300, 720, 300);

            //e.Graphics.DrawImage(image, 150, 865, image.Width, image.Height);
            e.Graphics.DrawString(StudentUserInfo.KSKM, new Font("宋体", 12, System.Drawing.FontStyle.Bold), Brushes.Black, 150, 650);
            e.Graphics.DrawString(StudentUserInfo.KSH, new Font("宋体", 130, System.Drawing.FontStyle.Bold), Brushes.Black, 20, 680);
            // e.Graphics.DrawLine(new Pen(Color.Black, (float)3.00), 100, 185, 720, 185);

            e.Graphics.DrawString("（备用）", new Font("宋体", 12), Brushes.Black, 560, 650);
            e.Graphics.DrawString("身份证号：", new Font("宋体", 12), Brushes.Black, 480, 690);
            e.Graphics.DrawString(StudentUserInfo.SFZH, new Font("宋体", 12, System.Drawing.FontStyle.Bold), Brushes.Black, 560, 690);
            e.Graphics.DrawString("姓名：" + StudentUserInfo.XM + "", new Font("宋体", 12), Brushes.Black, 480, 715);
            e.Graphics.DrawString("性别：" + StudentUserInfo.XB + "", new Font("宋体", 12), Brushes.Black, 480, 740);
            e.Graphics.DrawString("准考证号：", new Font("宋体", 12), Brushes.Black, 480, 765);
            e.Graphics.DrawString(StudentUserInfo.ZKZH, new Font("宋体", 12, System.Drawing.FontStyle.Bold), Brushes.Black, 560, 765);
            e.Graphics.DrawString("考试科目：" + StudentUserInfo.KSKM + "", new Font("宋体", 12), Brushes.Black, 480, 790);
            e.Graphics.DrawString("考试号：", new Font("宋体", 12), Brushes.Black, 480, 815);
            e.Graphics.DrawString(StudentUserInfo.KSH, new Font("宋体", 12, System.Drawing.FontStyle.Bold), Brushes.Black, 545, 815);
        }
        #endregion

        private void benQuery_Click(object sender, EventArgs e)
        {
            var dt = service.GetTB_Pad_SignedDataTable_New(SessionerHelper.ExamPlaceID, SessionerHelper.ExamLevel,
                SessionerHelper.SpecialityKindsNO, SessionerHelper.SystemYear, txtIdCard_Query.Text, txtName_Query.Text);
            gdAppointmentStudents.DataSource = dt;
            gridView2.OptionsSelection.MultiSelect = true;
            gridView2.OptionsSelection.MultiSelectMode = DevExpress.XtraGrid.Views.Grid.GridMultiSelectMode.RowSelect;
        }
    }
    public class UserInfo
    {
        /// <summary>
        /// 打印类型 【1：普通 2：线  3：圈】
        /// </summary>
        public int PrintType { get; set; }
        /// <summary>
        /// 身份证号
        /// </summary>
        public string SFZH { get; set; }
        /// <summary>
        /// 姓名
        /// </summary>
        public string XM { get; set; }
        /// <summary>
        /// 性别
        /// </summary>
        public string XB { get; set; }
        /// <summary>
        /// 准考证号
        /// </summary>
        public string ZKZH { get; set; }
        /// <summary>
        /// 考试科目
        /// </summary>
        public string KSKM { get; set; }
        /// <summary>
        /// 考试号
        /// </summary>
        public string KSH { get; set; }
    }
}

